<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>更新视频</title>
    <link rel="stylesheet" type="text/css" href="css/adminContent.css"/>
    <link rel="stylesheet" href="//unpkg.com/layui@2.6.8/dist/css/layui.css">
    <script src="//unpkg.com/layui@2.6.8/dist/layui.js"></script>
    <!-- 导入 Vue 3 -->
    <script src="https://unpkg.com/vue@next"></script>
    <script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
</head>
<body>
<div class="body">
    <form name="form1" id="form1">
        <table width="100%" cellspacing="0">
            <tr>
                <td colspan="2" style="text-align: center;color: red;" id="tip" v-html="tip"></td>
            </tr>
            <h1 style="text-align: center">更新视频</h1>
            <tr>
                <td width="46%">编号</td>
                <td><input v-model="video.vid" id="vid" disabled="disabled"/></td>
            </tr>
            <tr>
                <td>标题</td>
                <td><input v-model="video.vtitle" id="vtitle"/></td>
            </tr>
            <tr>
                <td>分栏</td>
                <td><input v-model="video.vlabel" id="vlabel"/></td>
            </tr>
            <tr>
                <td>视频链接</td>
                <td><input v-model="video.vurl" id="vurl"/></td>
            </tr>
            <tr>
                <td>封面链接</td>
                <td><input v-model="video.vcover" id="vcover"/></td>
            </tr>
            <tr>
                <td>简介</td>
                <td><input v-model="video.vcomment" id="vcomment"/></td>
            </tr>
            <tr>
                <td>上传时间</td>
                <td><input v-model="video.vuptime" id="vuptime"/></td>
            </tr>
            <tr>
                <td>播放量</td>
                <td><input v-model="video.vcount" id="vcount"/></td>
            </tr>
            <tr>
                <td>点赞量</td>
                <td><input v-model="video.vlike" id="vlike"/></td>
            </tr>
            <tr>
                <td>收藏量</td>
                <td><input v-model="video.vcollect" id="vcollect"/></td>
            </tr>

            <tr>
                <td colspan="2" id="btnPanel">
                    <input type="button" value="更新" @click="doUpdate()"/>
                    <input type="button" value="清空" @click="doClear()"/>
                </td>
            </tr>
        </table>
    </form>
</div>
</body>
<script src="../js/jquery-1.8.0.min.js" type="text/javascript" charset="utf-8"></script>
<script>
    Vue.createApp({
            data() {
                return {
                    video:{},
                    tip: '&nbsp;'
                }
            },
            methods:{
                doUpdate(){
                    let id = sessionStorage.getItem("vid");// 从 sessionStorage 中获取用户id
                    axios({
                        method:'post',
                        url:'/video/updateVideo',
                        params:{
                            vid:id,
                            vtitle:this.video.vtitle,
                            vlabel:this.video.vlabel,
                            vurl:this.video.vurl,
                            vcover:this.video.vcover,
                            vcomment:this.video.vcomment,
                            vuptime:this.video.vuptime,
                            vcount:this.video.vcount,
                            vlike:this.video.vlike,
                            vcollect:this.video.vcollect,
                            vdeleted:this.video.vdeleted,
                        }
                    }).then(res => {
                        let ret = res.data;
                        if(ret == true){
                            this.tip = "更新成功！";
                        }else{
                            this.tip = "更新失败！";
                        }
                    });
                },
                doClear() {
                    this.video = {
                        vid: '',
                        vtitle: '',
                        vlabel: '',
                        vurl: '',
                        vcover: '',
                        vcomment: '',
                        vuptime: '',
                        vcount: '',
                        vlike: '',
                        vcollect: '',
                        vdeleted: '',
                    }
                }
        },
        created()
    {
        let id = JSON.parse(sessionStorage.getItem("vid"));// 从 sessionStorage 中获取用户id
        axios({
            method: 'post',
            url: '/video/selectVideo?vid=' + id
        }).then(res => {
            this.video = res.data.data;
        });
    }
    }).mount("#form1");
</script>
</html>
    